package com.mallcai.bigdata.ladon.dpl.mapper.report;

import com.mallcai.bigdata.ladon.dpl.entity.report.QueryField;
import com.mallcai.bigdata.ladon.dpl.mapper.report.provider.QueryFieldSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface QueryFieldMapper {
    @InsertProvider(type = QueryFieldSqlProvider.class, method = "insert")
    int insert(QueryField queryField);

    @UpdateProvider(type = QueryFieldSqlProvider.class, method = "update")
    int update(QueryField queryField);

    @DeleteProvider(type = QueryFieldSqlProvider.class, method = "delete")
    int delete(QueryField queryField);

    @Select({
            "SELECT * FROM " + QueryFieldSqlProvider.TB_QUERY_FIELD + " WHERE archive = 0 AND report_id = #{reportId} ORDER BY sort_id"
    })
    List<QueryField> getByReportId(@Param("reportId") Long reportId);

    @Delete({
            "DELETE FROM " + QueryFieldSqlProvider.TB_QUERY_FIELD + " WHERE report_id = #{reportId}"
    })
    int delByReportId(@Param("reportId") Long reportId);
}
